var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "react", "mobile/services/memberService", "maishu-services-sdk", "components/common/base-component", "components/common/component"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    const React = require("react");
    const memberService_1 = require("mobile/services/memberService");
    const maishu_services_sdk_1 = require("maishu-services-sdk");
    const base_component_1 = require("components/common/base-component");
    const component_1 = require("components/common/component");
    let LocationBarControl = class LocationBarControl extends base_component_1.BaseComponent {
        constructor(props) {
            super(props);
            this.state = {};
            this.memberService = this.createService(memberService_1.MemberService);
            this.imageService = this.createService(maishu_services_sdk_1.ImageService);
        }
        componentDidMount() {
            this.memberService.store().then(store => {
                this.setState({ store: store });
            });
        }
        render() {
            /**
             * 要在控件设置和控件大小相关的样式，例如 padding，margin，height
             */
            let type = this.props.type;
            if (type == "displayLocation") {
                return this.renderLocation();
            }
            return this.renderStore();
        }
        renderStore() {
            let { store } = this.state;
            let { showStoreLogo } = this.props;
            return React.createElement("div", { className: "location-bar-store", style: { padding: 14, height: 50 } },
                React.createElement("i", { className: "icon-user pull-right", onClick: () => this.app.forward("user/index") }),
                React.createElement("div", { className: "position interception" },
                    showStoreLogo ? React.createElement("img", { style: { width: 18, height: 18 }, className: "img-circle", src: this.imageService.imageSource(store ? store.ImagePath : "") }) : null,
                    React.createElement("span", null, store ? store.Name : "")));
        }
        renderLocation() {
            return React.createElement("div", { className: "location-bar", style: { padding: 14 } },
                React.createElement("i", { className: "icon-user pull-right", onClick: () => this.app.redirect("user/index") }),
                React.createElement("div", { className: "position interception" },
                    React.createElement("i", { className: "icon-map-marker" }),
                    React.createElement("span", null, "\u6682\u65F6\u83B7\u53D6\u4E0D\u5230\u4F4D\u7F6E\u4FE1\u606F"),
                    React.createElement("i", { className: "icon-sort-down", style: { margin: 0, position: 'relative', left: 6, top: -2 } })));
        }
    };
    LocationBarControl.defaultProps = { type: "displayStoreName", showStoreLogo: true };
    LocationBarControl = __decorate([
        component_1.component({ displayName: "店铺顶栏", icon: "icon-map-marker", introduce: "在顶部显示购物车图标，显示用户位置" })
    ], LocationBarControl);
    exports.LocationBarControl = LocationBarControl;
});
